package com.heima.admin.controller.v1;

import com.heima.admin.service.ChannelService;
import com.heima.model.admin.pojo.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道列表controller",tags = "频道列表controller")
public class AdChannelController {
    @Autowired
    private ChannelService channelService;

    /**
     * wemedia远程调用查询敏感词
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult findAllList(){
        List<AdChannel> list = channelService.list();
        return ResponseResult.okResult(list);
    }

    /**
     * 根据id查询频道
      * @param id
     * @return
     */
    @ApiOperation("根据id查询频道")
    @GetMapping("/one/{id}")
    public ResponseResult findOne(@PathVariable Integer id) {
        return ResponseResult.okResult(channelService.getById(id));
    }

}
